
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>第七章 Excel函数-动态函数 &#8212; free-excel</title>
<script>
  document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
  document.documentElement.dataset.theme = localStorage.getItem("theme") || "light"
</script>

  <!-- Loaded before other Sphinx assets -->
  <link href="../_static/styles/theme.css?digest=92025949c220c2e29695" rel="stylesheet">
<link href="../_static/styles/pydata-sphinx-theme.css?digest=92025949c220c2e29695" rel="stylesheet">


  <link rel="stylesheet"
    href="../_static/vendor/fontawesome/5.13.0/css/all.min.css">
  <link rel="preload" as="font" type="font/woff2" crossorigin
    href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
  <link rel="preload" as="font" type="font/woff2" crossorigin
    href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">

    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../_static/css/s4defs-roles.css" />

  <!-- Pre-loaded scripts that we'll load fully later -->
  <link rel="preload" as="script" href="../_static/scripts/pydata-sphinx-theme.js?digest=92025949c220c2e29695">

    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/sphinx_highlight.js"></script>
    <link rel="shortcut icon" href="../_static/logo.ico"/>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="第八章Excel数据可视化" href="chap8.html" />
    <link rel="prev" title="第六章 Excel函数-查找函数" href="chap6.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en">
  </head>
  
  
  <body data-spy="scroll" data-target="#bd-toc-nav" data-offset="180" data-default-mode="">
    <div class="bd-header-announcement container-fluid" id="banner">
      

    </div>

    
    <nav class="bd-header navbar navbar-light navbar-expand-lg bg-light fixed-top bd-navbar" id="navbar-main"><div class="bd-header__inner container-xl">

  <div id="navbar-start">
    
    
  


<a class="navbar-brand logo" href="../index.html">
  
  
  
  
    <img src="../_static/logo.svg" class="logo__image only-light" alt="Logo image">
    <img src="../_static/logo.svg" class="logo__image only-dark" alt="Logo image">
  
  
</a>
    
  </div>

  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-collapsible" aria-controls="navbar-collapsible" aria-expanded="false" aria-label="Toggle navigation">
    <span class="fas fa-bars"></span>
  </button>

  
  <div id="navbar-collapsible" class="col-lg-9 collapse navbar-collapse">
    <div id="navbar-center" class="mr-auto">
      
      <div class="navbar-center-item">
        <ul id="navbar-main-elements" class="navbar-nav">
    <li class="toctree-l1 nav-item">
 <a class="reference internal nav-link" href="../%E4%B8%BB%E9%A1%B5.html">
  主页
 </a>
</li>

<li class="toctree-l1 current active nav-item">
 <a class="reference internal nav-link" href="index.html">
  教程
 </a>
</li>

<li class="toctree-l1 nav-item">
 <a class="reference internal nav-link" href="../%E4%BD%9C%E8%80%85.html">
  作者
 </a>
</li>

<li class="toctree-l1 nav-item">
 <a class="reference internal nav-link" href="../Datawhale.html">
  Datawhale
 </a>
</li>

<li class="toctree-l1 nav-item">
 <a class="reference internal nav-link" href="../%E7%BB%83%E4%B9%A0%E9%A2%98%E5%8F%82%E8%80%83%E6%93%8D%E4%BD%9C.html">
  练习题参考操作
 </a>
</li>

    
</ul>
      </div>
      
    </div>

    <div id="navbar-end">
      
      <div class="navbar-end-item">
        <span id="theme-switch" class="btn btn-sm btn-outline-primary navbar-btn rounded-circle">
    <a class="theme-switch" data-mode="light"><i class="fas fa-sun"></i></a>
    <a class="theme-switch" data-mode="dark"><i class="far fa-moon"></i></a>
    <a class="theme-switch" data-mode="auto"><i class="fas fa-adjust"></i></a>
</span>
      </div>
      
      <div class="navbar-end-item">
        <ul id="navbar-icon-links" class="navbar-nav" aria-label="Icon Links">
        <li class="nav-item">
          <a class="nav-link" href="https://github.com/datawhalechina/free-excel" rel="noopener" target="_blank" title="GitHub"><span><i class="fab fa-github-square"></i></span>
            <label class="sr-only">GitHub</label></a>
        </li>
      </ul>
      </div>
      
    </div>
  </div>
</div>
    </nav>
    

    <div class="bd-container container-xl">
      <div class="bd-container__inner row">
          

<!-- Only show if we have sidebars configured, else just a small margin  -->
<div class="bd-sidebar-primary col-12 col-md-3 bd-sidebar">
  <div class="sidebar-start-items"><form class="bd-search d-flex align-items-center" action="../search.html" method="get">
  <i class="icon fas fa-search"></i>
  <input type="search" class="form-control" name="q" id="search-input" placeholder="在这里搜索" aria-label="在这里搜索" autocomplete="off" >
</form><nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
  <div class="bd-toc-item active">
    <ul class="current nav bd-sidenav">
 <li class="toctree-l1">
  <a class="reference internal" href="chap1.html">
   第一章 Excel与数据格式
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap2.html">
   第二章 Excel的快捷操作
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap3.html">
   第三章 Excel的表合并
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap4.html">
   第四章 Excel函数-逻辑判断
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap5.html">
   第五章 Excel函数-文本函数
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap6.html">
   第六章 Excel函数-查找函数
  </a>
 </li>
 <li class="toctree-l1 current active">
  <a class="current reference internal" href="#">
   第七章 Excel函数-动态函数
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap8.html">
   第八章Excel数据可视化
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap9.html">
   第九章Excel数据透视
  </a>
 </li>
 <li class="toctree-l1">
  <a class="reference internal" href="chap10.html">
   第十章Excel看板
  </a>
 </li>
</ul>

  </div>
</nav>
  </div>
  <div class="sidebar-end-items">
  </div>
</div>


          


<div class="bd-sidebar-secondary d-none d-xl-block col-xl-2 bd-toc">
  
    
    <div class="toc-item">
      
<div class="tocsection onthispage mt-5 pt-1 pb-3">
    <i class="fas fa-list"></i> On this page
</div>

<nav id="bd-toc-nav">
    <ul class="visible nav section-nav flex-column">
 <li class="toc-h2 nav-item toc-entry">
  <a class="reference internal nav-link" href="#filter">
   1.FILTER函数
  </a>
  <ul class="nav section-nav flex-column">
   <li class="toc-h3 nav-item toc-entry">
    <a class="reference internal nav-link" href="#header-n107">
     案例1
    </a>
   </li>
   <li class="toc-h3 nav-item toc-entry">
    <a class="reference internal nav-link" href="#header-n114">
     案例2
    </a>
   </li>
   <li class="toc-h3 nav-item toc-entry">
    <a class="reference internal nav-link" href="#header-n123">
     案例3
    </a>
   </li>
  </ul>
 </li>
 <li class="toc-h2 nav-item toc-entry">
  <a class="reference internal nav-link" href="#subtotal">
   2.SUBTOTAL函数
  </a>
 </li>
 <li class="toc-h2 nav-item toc-entry">
  <a class="reference internal nav-link" href="#id4">
   练习
  </a>
 </li>
</ul>

</nav>
    </div>
    
    <div class="toc-item">
      
    </div>
    
  
</div>


          
          
          <div class="bd-content col-12 col-md-9 col-xl-7">
              
              <article class="bd-article" role="main">
                
  <div class="section" id="excel">
<span id="header-n98"></span><h1>第七章 Excel函数-动态函数<a class="headerlink" href="#excel" title="Permalink to this heading">#</a></h1>
<blockquote>
<div><p>在本节中会讲解一些Excel更新的动态函数，从而帮助大家更好的掌握Excel的数据处理与分析</p>
</div></blockquote>
<div class="section" id="filter">
<span id="header-n102"></span><h2>1.FILTER函数<a class="headerlink" href="#filter" title="Permalink to this heading">#</a></h2>
<blockquote>
<div><p>在工作中，我们需要根据指定的条件，将符合条件的所有记录从数据源表格式查找过来，一是可以用高级筛选。但高级筛选在查询下一个单位时
，需要重新设置一次，很麻烦。二是用函数公式查询。典型的套路有：INDEX+SMALL+ROW、或者LOOKUP+COUNTIF+OFFSET，而这样的方法对初学者非常不友好，而EXCEL新更新的感受FILTER可以很好的解决这个问题。</p>
</div></blockquote>
<p>【FILTER】函数=FILTER（数据区域，筛选条件，[无满足条件的记录时返回的值]）</p>
<p>接下来就看看FILTER的实际应用案例</p>
<div class="section" id="header-n107">
<span id="id1"></span><h3>案例1<a class="headerlink" href="#header-n107" title="Permalink to this heading">#</a></h3>
<p>打开<code class="docutils literal notranslate"><span class="pre">data/chap7/7.1xlsx</span></code>中的【案例1】</p>
<p>获得湖北区的相关数据</p>
<p>在J2单元格中输入</p>
<p><strong>=FILTER(A2:G30,C2:C30=”湖北区”)</strong> 注意数据区域不包含标题</p>
<p>生成的数据的动态数组（WPS由于不兼容动态数组，稍微和Excel有点区别，会产生数据溢出的情况）</p>
<div class="figure align-default">
<img alt="" src="../_images/7.1.gif" />
</div>
</div>
<div class="section" id="header-n114">
<span id="id2"></span><h3>案例2<a class="headerlink" href="#header-n114" title="Permalink to this heading">#</a></h3>
<p>打开<code class="docutils literal notranslate"><span class="pre">data/chap7/7.1xlsx</span></code>中的【案例1】</p>
<p>如果在实际的任务中不需要所有的列，只需要其中的几行，那么应该怎么操作？</p>
<p>可以在K2单元格中输入</p>
<p><strong>=FILTER(F2:G30,C2:C30=”湖北区”)</strong></p>
<p>细心的同学就发现了这里与7.1.1中的不同，如果需要返回其中的几行，只需要将数据区域修改为自己需要的区域即可</p>
<p>现在需要知道湖北区的最大销售金额是多少</p>
<p><strong>=MAX(FILTER(F2:F30,C2:C30=”湖北区”))</strong></p>
<div class="figure align-default">
<img alt="" src="../_images/7.2.gif" />
</div>
</div>
<div class="section" id="header-n123">
<span id="id3"></span><h3>案例3<a class="headerlink" href="#header-n123" title="Permalink to this heading">#</a></h3>
<p>打开<code class="docutils literal notranslate"><span class="pre">data/chap7/7.1xlsx</span></code>中的【案例1】</p>
<p>FILTER函数中的多条件筛选，使用<code class="docutils literal notranslate"><span class="pre">+</span></code>来表示或，使用<code class="docutils literal notranslate"><span class="pre">*</span></code>表示且</p>
<p>例如，需要计算湖北区、湖南区大最大销售金额，那么函数公式为</p>
<p><strong>=MAX(FILTER(F2:F30,(C2:C30=”湖北区”)+(C2:C30=”湖南区”)))</strong></p>
<div class="figure align-default">
<img alt="" src="../_images/7.3.gif" />
</div>
<p>例如，需要计算湖北区商品2的最大销售金额，那么函数公式为</p>
<p><strong>=MAX(FILTER(F2:F30,(C2:C30=”湖北区”)*(D2:D30=”商品2”)))</strong></p>
<div class="figure align-default">
<img alt="" src="../_images/7.4.gif" />
</div>
</div>
</div>
<div class="section" id="subtotal">
<span id="header-n132"></span><h2>2.SUBTOTAL函数<a class="headerlink" href="#subtotal" title="Permalink to this heading">#</a></h2>
<p>Excel中有数据筛选非常好用，那么，如果想统计筛选后的结果应该怎么弄？例如想知道筛选后的销售总额</p>
<p>打开<code class="docutils literal notranslate"><span class="pre">data/chap7/7.2xlsx</span></code>中的案例1，使用筛选选择不同的区，而SUM求和并没有变化</p>
<p>如果想实现上述需求，可以使用【SUBTOTAL函数】</p>
<p>【SUBTOTAL函数】=SUBTOTAL(功能函数,选择区域)</p>
<p>功能函数</p>
<p>数字 1-11 或 101-111，用于指定要为分类汇总使用的函数。 如果使用
1-11，将包括手动隐藏的行，如果使用
101-111，则排除手动隐藏的行；始终排除已筛选掉的单元格。详见附件1</p>
<p>在J2单元格中输入如下公式</p>
<p><strong>=SUBTOTAL(9,F2:F21)</strong></p>
<p>可以看到SUBTOTAL对筛选的数据列进行正确的求和，而SUM无法跟随选择的数据列进行正确求和</p>
<div class="figure align-default">
<img alt="" src="../_images/7.5.gif" />
</div>
<p>【附件1】</p>
<div class="figure align-default">
<img alt="" src="../_images/7.6.png" />
</div>
</div>
<div class="section" id="id4">
<h2>练习<a class="headerlink" href="#id4" title="Permalink to this heading">#</a></h2>
<p>1.打开<code class="docutils literal notranslate"><span class="pre">data/chap7/7.1xlsx</span></code>中的【案例1】计算河北区中商品1的最小销售额</p>
<p>2.打开<code class="docutils literal notranslate"><span class="pre">data/chap7/7.1xlsx</span></code>中的【案例1】计算湖北中什么渠道下的什么商品具有最高销售额</p>
</div>
</div>


              </article>
              

              
          </div>
          
      </div>
    </div>

  
  
  <!-- Scripts loaded after <body> so the DOM is not blocked -->
  <script src="../_static/scripts/pydata-sphinx-theme.js?digest=92025949c220c2e29695"></script>

<footer class="bd-footer"><div class="bd-footer__inner container">
  
  <div class="footer-item">
    <p class="copyright">
    &copy; Copyright 2022, Datawhale, 牧小熊.<br>
</p>
  </div>
  
  <div class="footer-item">
    <p class="sphinx-version">
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 5.3.0.<br>
</p>
  </div>
  
</div>
</footer>
  </body>
</html>